package com.qishon.pc.domain.service;

import com.qishon.pc.domain.util.CutOutUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * Created by yongwei.chen on 2017/1/9.
 */
@Component
@Slf4j
@RabbitListener(queues = "cutoutReceiver")
public class CutOutReceiverService {
    @Value("${run.path}")
    private String filePath;

    @Value("${cutout.tools.path}")
    private String cutPath;

    @Value("${cutout.tools.channelEdgeValue}")
    private String channelEdgeValue;

    @RabbitHandler
    public void process(String msg){
        log.info("cutoutReceiver:" + msg);
        String[] str = msg.split(",");
        String CmdPath = cutPath;
        String path = filePath +"\\"+"02.Render"+"\\"+str[2];
        String savePath = filePath +"\\"+"03.Cutout";
        try {
            CutOutUtil.PsTools(CmdPath,channelEdgeValue,path,savePath);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
